Skip to content

lsp-format-region: Fix error "no region" #4827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sunlin7
Copy link
Contributor

@sunlin7 sunlin7 commented Jul 1, 2025

The lsp-format-region will emit error message The mark is not set now, so there is no region at the very beginning.
It can be reproduced with follow steps:
Start the Emacs with lsp, and open a c++ file /tmp/a.cpp, and execute lsp-format-region, then got the error message.

To workaround the issue, just select one char/word and de-select the region, then execute the lsp-format-region.

This PR will follow the document of lsp-format-region description to accept region or line.

Please help review and approve this change, thanks

@jcs090218
Copy link
Member

Isn't that the expected behaviour? 🤔 lsp-format-region without selecting a region isn't allowed.

@sunlin7
Copy link
Contributor Author

sunlin7 commented Jul 2, 2025

@jcs090218
No. The document of lsp-format-region says it should be current line when no region been selected:
Ask the server to format the region, or if none is selected, the current line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants